<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>SWM34S_LVGL7.11_SWMUI: C:/Users/DELL/Desktop/Commit/lvgl/SWM34S_LVGL7.11_SWMUI_20230515/APP/BSP/dev_crc.c 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">SWM34S_LVGL7.11_SWMUI<span id="projectnumber">&#160;V7.9</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.5 -->
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_0ca16891106f5a3e9ad635a0d6c5f98f.html">APP</a></li><li class="navelem"><a class="el" href="dir_4ca18d753a70f6eada20fde478bd3fc8.html">BSP</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle"><div class="title">dev_crc.c</div></div>
</div><!--header-->
<div class="contents">
<a href="dev__crc_8c.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &quot;<a class="code" href="dev__crc_8h.html">dev_crc.h</a>&quot;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span> </div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"><a class="line" href="dev__crc_8c.html#a5637ce34d6452f02914d3be9e0f7ae50">   25</a></span><span class="keyword">static</span> <span class="keyword">const</span> uint32_t <a class="code hl_variable" href="dev__crc_8c.html#a5637ce34d6452f02914d3be9e0f7ae50">CRC_Init_Value</a> = 0xFFFFFFFF;</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span> </div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"><a class="line" href="dev__crc_8c.html#af9273c2c56ccb1b14946a43defe57f6b">   31</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="dev__crc_8c.html#af9273c2c56ccb1b14946a43defe57f6b">crc_init</a>(<span class="keywordtype">void</span>)</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span>{</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span>    CRC_InitStructure CRC_initStruct;</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span>    CRC_initStruct.init_crc = <a class="code hl_variable" href="dev__crc_8c.html#a5637ce34d6452f02914d3be9e0f7ae50">CRC_Init_Value</a>;</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span>    CRC_initStruct.Poly = CRC_POLY_104C11DB7;</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span>    CRC_initStruct.in_width = CRC_WIDTH_32;</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span> </div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span><span class="comment">/* 翻转方式 :</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span><span class="comment">#define CRC_REV_NOT         0   // bit顺序不变</span></div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span><span class="comment">#define CRC_REV_ALL         1   // bit顺序完全翻转    (32 位数据宽度 31:0 -&gt; 0:31；                     16 位数据宽度 15:0 -&gt; 0:15；      8位数据宽度 7:0 -&gt; 0:7)</span></div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span><span class="comment">#define CRC_REV_IN_BYTE     2   // bit顺序字节内翻转 (32 位数据宽度 31:0 -&gt; 24:31, 16:23, 8:15, 0:7；        16位数据宽度 15:0 -&gt; 8:15, 0:7)</span></div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span><span class="comment">#define CRC_REV_BYTE        3   // 仅字节顺序翻转  (32 位数据宽度 31:0 -&gt; 7:0,15:8,23:16,31:24；     16 位数据宽度 15:0 -&gt; 7:0,15:8)</span></div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span><span class="comment">*/</span></div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span> </div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span>    CRC_initStruct.in_rev = CRC_REV_NOT;</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span>    CRC_initStruct.in_not = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span>    CRC_initStruct.out_rev = CRC_REV_NOT;</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span>    CRC_initStruct.out_not = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno">   49</span>    CRC_Init(CRC, &amp;CRC_initStruct);</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span>}</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span> </div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"><a class="line" href="dev__crc_8c.html#a64e0abe6c28e0480424c1e467afb7430">   57</a></span>uint32_t <a class="code hl_function" href="dev__crc_8c.html#a64e0abe6c28e0480424c1e467afb7430">get_crc32</a>(uint32_t data)</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span>{</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span>    <span class="comment">/* 重算一遍 */</span></div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span>    CRC_SetInitVal(CRC, <a class="code hl_variable" href="dev__crc_8c.html#a5637ce34d6452f02914d3be9e0f7ae50">CRC_Init_Value</a>);</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span>    CRC_Write(data);</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span>    <span class="keywordflow">return</span> CRC_Result();</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span>}</div>
<div class="ttc" id="adev__crc_8c_html_a5637ce34d6452f02914d3be9e0f7ae50"><div class="ttname"><a href="dev__crc_8c.html#a5637ce34d6452f02914d3be9e0f7ae50">CRC_Init_Value</a></div><div class="ttdeci">static const uint32_t CRC_Init_Value</div><div class="ttdoc">注意初值设定需要与用户外部计算器设置保持一致 0xFFFFFFFF or 0</div><div class="ttdef"><b>Definition:</b> <a href="dev__crc_8c_source.html#l00025">dev_crc.c:25</a></div></div>
<div class="ttc" id="adev__crc_8c_html_a64e0abe6c28e0480424c1e467afb7430"><div class="ttname"><a href="dev__crc_8c.html#a64e0abe6c28e0480424c1e467afb7430">get_crc32</a></div><div class="ttdeci">uint32_t get_crc32(uint32_t data)</div><div class="ttdoc">计算 CRC32 校验和</div><div class="ttdef"><b>Definition:</b> <a href="dev__crc_8c_source.html#l00057">dev_crc.c:57</a></div></div>
<div class="ttc" id="adev__crc_8c_html_af9273c2c56ccb1b14946a43defe57f6b"><div class="ttname"><a href="dev__crc_8c.html#af9273c2c56ccb1b14946a43defe57f6b">crc_init</a></div><div class="ttdeci">void crc_init(void)</div><div class="ttdoc">硬件 CRC 初始化</div><div class="ttdef"><b>Definition:</b> <a href="dev__crc_8c_source.html#l00031">dev_crc.c:31</a></div></div>
<div class="ttc" id="adev__crc_8h_html"><div class="ttname"><a href="dev__crc_8h.html">dev_crc.h</a></div><div class="ttdoc">硬件 CRC</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5
</small></address>
</body>
</html>
